package com.lhf.novel.event;

import com.lhf.novel.mail.MailService;
import lombok.SneakyThrows;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * MailListener实体类
 *
 * @author zy 刘会发
 * @since 2020/3/11$
 */
@Component
public class MailListener implements ApplicationListener<MailEvent> {
    @Resource
    private MailService mailService;

    @SneakyThrows
    @Override
    public void onApplicationEvent(MailEvent event) {
        mailService.sendMail(event.getTo(), event.getTitle(), event.getMes());
    }
}
